package com.nwcl.ysx.request;

import com.nwcl.common.request.BaseRequest;
import com.nwcl.common.result.Result;
import com.nwcl.common.utils.DateUtil;
import org.apache.commons.lang3.StringUtils;

import java.util.Date;

/**
 * @author liguiqin
 * @date 2023/5/26
 */
public class RoomSubscribeRequest implements BaseRequest {
    private Integer roomId;//房间id
    private String phone;//手机号
    private Integer people;//人数
    private String startTime;//预约开始时间
    private String endTime;//预约结束时间
    private String remark;//备注
    @Override
    public Result check() {
        if(roomId==null){
            return Result.fail("房间id不能为空");
        }
        if(StringUtils.isBlank(phone)){
            return Result.fail("手机号不能为空");
        }
        if(people==null){
            return Result.fail("人数不能为空");
        }
        if(StringUtils.isBlank(startTime)){
            return Result.fail("开始时间不能为空");
        }
        if(StringUtils.isBlank(endTime)){
            return Result.fail("结束时间不能为空");
        }
        Date nowDate = DateUtil.getDateStart(new Date());
        Date startDate = DateUtil.getDateStart(DateUtil.parseDateTime(startTime));
        if(1>DateUtil.getDiffDays(nowDate,startDate)){
            return Result.fail("请提前一天预约");
        }
        if(DateUtil.parseDateTime(startTime).getTime()>DateUtil.parseDateTime(endTime).getTime()){
            return Result.fail("结束时间不能小于开始时间");
        }
        return null;
    }

    public Integer getRoomId() {
        return roomId;
    }

    public void setRoomId(Integer roomId) {
        this.roomId = roomId;
    }

    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }

    public Integer getPeople() {
        return people;
    }

    public void setPeople(Integer people) {
        this.people = people;
    }

    public String getStartTime() {
        return startTime;
    }

    public void setStartTime(String startTime) {
        this.startTime = startTime;
    }

    public String getEndTime() {
        return endTime;
    }

    public void setEndTime(String endTime) {
        this.endTime = endTime;
    }

    public String getRemark() {
        return remark;
    }

    public void setRemark(String remark) {
        this.remark = remark;
    }
}
